/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package plan.mobile;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import mobile.Call;
import mobile.Message;
import mobile.MobileConsumption;
import plan.Plan;
import turnover.Consumption;

/**
 *
 * @author Alberto
 */
public class Orange_Contrato_Libre extends Plan {

    private double startQuote = 15d;
    private double minuteCost=0.24d;
    private double messageCost = 0.15d;

    /*El Contrato Decreciente es compatible con todas las promociones Orange y
    con  todos los módulos de ahorro, a excepción de  Mis 5 de Orange.*/
   
    public Orange_Contrato_Libre() {
        super.setName("Orange Contrato Libre");
    }

    public double getStartQuote() {
        return startQuote;
    }

    @Override
    public double getCost(Consumption consumption) {

        double total = 0d;
        MobileConsumption mc = (MobileConsumption) consumption;
        Iterator it = mc.getCallList().listIterator();
        while (it.hasNext()) {
            Call c = (Call) it.next();
            if (c.isSpecial()) {
                total += c.getCost();
            }
            else if ( c.isMobile() || c.isFixedLineTelephone()) {
                total += c.getDuration().changeSeconds() * this.minuteCost / 60;
            }
        }
        it = mc.getMessList().listIterator();
        while (it.hasNext()) {
            Message m = (Message) it.next();
            if (m.isSpecial()) {
                total += m.getCost();
            } else {
                total += this.messageCost;
            }
        }
        if (total<6d){
            total = 6d;
        }
        total += total * 0.16d;
        return total;
    }

    public double getMessageCost() {
        return messageCost;
    }

    public double getMinuteCost() {
        return minuteCost;
    }
}

